\documentclass[12pt]{article}
\usepackage{times}
\usepackage{graphicx}
\usepackage{sidecap}
\usepackage{wrapfig}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\baselinestretch}{1.2}
\newenvironment{mylisting}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\scriptsize\bfseries}
{\end{list}}
\newenvironment{mylisting2}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\scriptsize\bfseries}
{\end{list}}

%%% This file is Open Content

\begin{document}
	\textbf{{\Huge Rocketman}}
{\center{Dec 29, 2011, 
	Johan Ceuppens, Theo D'Hondt - Vrije Universiteit Brussel}}
\\
{\large{\textbf{\center Abstract}}}
\\
\\
\section{\large Introduction}



\begin{mylisting}
\begin{verbatim}

	
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;
import java.util.Observable;
import java.io.IOException;

public class AIengine extends Observable implements Runnable
{
protected String currentmessage = "None";
public AIengine()
{
}

//run once per message dispatch (messageEngine method)
public void run()
{
		setChanged();
		notifyObservers(currentmessage);
/*	
	for (int i = 0; i < enemies.size(); i++) {
		if (enemies.get(i) != null) {
			enemies.get(i).message(currentmessage);
		}
	}
*/  

}

public void message(Enemy e)
{
	e.message(this);
}

public void messageEngine(String m)
{
	currentmessage = m;
	run();
}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class AIPlayerStateMove1 implements AIState 
{
public void move(Player player/*AIStateMove statemove*/)
{
	player.moveP();
}
public Player initPlayer(int playernumber,int xx,int yy)
{
	return null;
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class AIPlayerStateMove2Fall1 implements AIState 
{
private Player player;
public void move(Player pl)
{
	player = pl;
	player.moveP();
}
public Player initPlayer(int playernumber,int xx, int yy)
{
	return (new PlayerLevel2Fall1(xx,yy));
}
};


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class AIPlayerStateMove2Fall2 implements AIState 
{
private Player player;
public void move(Player pl)
{
	player = pl;
	player.moveP();
}
public Player initPlayer(int playernumber, int xx, int yy)
{
	player = new PlayerLevel2Fall2(xx,yy);
	return player;
}
};



package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class AIPlayerStateMove2Fall3 implements AIState 
{
private Player player;
public void move(Player pl)
{
	player = pl;
	player.moveP();
}
public Player initPlayer(int playernumber,int xx, int yy)
{
	player = new PlayerLevel2Fall3(xx,yy);
	return player;
}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class AIPlayerStateMove2Fall4 implements AIState 
{
private Player player;
public void move(Player pl)
{
	player = pl;
	player.moveP();
}
public Player initPlayer(int playernumber,int xx, int yy)
{
	player = new PlayerLevel2Fall4(xx,yy);
	return player;
}
};


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class AIPlayerStateMove2 implements AIState 
{
private Player player;
public void move(Player pl)
{
	player = pl;
	player.moveP();
}
public Player initPlayer(int playernumber, int xx, int yy)
{
	System.out.println("playernumber="+playernumber);
	//NOTE: inheritance with instanceof
	//if (player instanceof PlayerLevel2Fall4) {

	if (playernumber == 5) {
		player = new PlayerLevel2Fall4(xx,yy);
	}
	else if (playernumber == 4) {
		player = new PlayerLevel2Fall4(xx,yy);
	} else if (playernumber == 3) {
		player = new PlayerLevel2Fall3(xx,yy);
	} else if (playernumber == 2) {
		System.out.println("foo ctor");
		player = new PlayerLevel2Fall2(xx,yy);
	} else if (playernumber == 1) {
		player = new PlayerLevel2Fall1(xx,yy);
	} else if (playernumber == 0) {
		player = new PlayerLevel2(xx,yy);
	}
	return player;
}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class AIPlayerStateMove3 implements AIState 
{
private Player player;
public void move(Player pl/*AIStateMove statemove*/)
{
	player = pl;
	player.moveP();
}
public Player initPlayer(int playernumber,int xx,int yy)
{
	player = new PlayerLevel3(100,500);
	return player;
}

};





package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class AIPlayerStateMove
{
private AIState my_state;
public AIPlayerStateMove(int levelnumber, int pln) {
	if (levelnumber == 1)
		setState(new AIPlayerStateMove1());
	else if (levelnumber == 2)
		setState(new AIPlayerStateMove2());
	else if (levelnumber == 3) 
		setState(new AIPlayerStateMove3());


}
public void setState(AIState ns) {
	this.my_state = ns;
}
public void move(Player player) {
	this.my_state.move(player);
}
public Player initPlayer(int playernumber, int xx, int yy)
{
	return this.my_state.initPlayer(playernumber,xx,yy);
}
};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

interface AIState 
{
public void move(Player player/*AIStateMove statemove*/);
public Player initPlayer(int playernumber/*AIStateMove statemove*/,int xx, int yy);
}

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class AIStateMove1 implements AIState 
{
public void move(Player player/*AIStateMove statemove*/)
{}
public Player initPlayer(int playernumber,int xx, int yy)
{
	return null;
}

};



package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class AIStateMove
{
private AIState my_state;
public AIStateMove() {
	setState(new AIStateMove1());
}
public void setState(AIState ns) {
	this.my_state = ns;
}
public void move(Player player) {
	this.my_state.move(player);
}
};




package rocketman;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class Bullet extends Entity 
{
public Bullet(int startx, int starty, String filename)
{
	super(startx, starty, filename);
}

};

package rocketman;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class BulletSnakeHead extends Bullet
{
public BulletSnakeHead(int startx, int starty, String filename)
{
	super(startx, starty, filename);
	setdx(-3);
	setdy(3);
}

};


package rocketman;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class BulletTargetted extends Bullet
{
protected int counter = 0;
protected int playerx, playery;
protected double bulletspeed = 1;
public BulletTargetted(int startx, int starty, String filename, int px, int py, double bulletspd)
{
	super(startx, starty, filename);
	
	bulletspeed = bulletspd;

	playerx = px;
	playery = py;

	if (playerx == 0)
		playerx = 1;
	if (playery == 0)
		playery = 1;

	double ricox,ricoy;
	ricox = (double)Math.abs(playerx-getx());
	ricoy = (double)Math.abs(playery-gety());

	if (playerx <= getx() && playery <= gety()) {
		dx2 = - Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 = - Math.abs(playery-gety())/(ricox/ricoy);
	}
	else if (playerx >= getx() && playery <= gety()) {
		dx2 =   Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 = - Math.abs(playery-gety())/(ricox/ricoy);
	}
	else if (playerx <= getx() && playery >= gety()) {
		dx2 = - Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 =   Math.abs(playery-gety())/(ricox/ricoy);
	}
	else if (playerx >= getx() && playery >= gety()) {
		dx2 =   Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 =   Math.abs(playery-gety())/(ricox/ricoy);
	}
	dx2 *= (double)(bulletspeed/distance(playerx,getx(),playery,gety()));
	dy2 *= (double)(bulletspeed/distance(playerx,getx(),playery,gety()));
}

public void  move()
{
	counter += 1;
	//if (counter == bulletspeed) 
	{
		counter = 0;
		if (dx2 != 0) {
			x += (int)(dx2/*-bulletspeed*/);
		}
		if (dy2 != 0) {
			y += (int)(dy2/*-bulletspeed*/);
		}
	}
}

};


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class EnemyBasilisk extends Enemy
{
public EnemyBasilisk(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename, 6,aiengine);
	setdx(0);
	setdy(0);
	imgs = new StateImageLibrary();
	addImage("basilisk200x150-1.png");
}

public void  move()
{
}
};



package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class EnemyDuergarSatteliteShip2 extends EnemyDuergarSatteliteShip
{
public EnemyDuergarSatteliteShip2(int startx, int starty, String filename, int hp, AIengine aiengine)
{
	super(startx, starty, filename,hp,aiengine);
	setdx(-3);
	setdy(3);
}

};


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class EnemyDuergarSatteliteShip extends Enemy
{
protected int shootcounter = 0;
public EnemyDuergarSatteliteShip(int startx, int starty, String filename, int hp, AIengine aiengine)
{
	super(startx, starty, filename,hp,aiengine);
	setdx(3);
	setdy(3);
}

public void shoot(LinkedList<Bullet> bullets, Player player)
{
	shootcounter += 1;
	if (shootcounter > 40) {
    		bullets.add(new EnemyRocket(getx(),gety(), "rocket20x20-1.png",player.getx(),player.gety(),8));
		shootcounter = 0;
	}
}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class EnemyDuergarShip1 extends EnemyTargetted
{
public EnemyDuergarShip1(int startx, int starty, String filename, int px, int py, double spd, AIengine aiengine)
{
	super(startx, starty, filename,px,py,spd,aiengine);
}

};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class EnemyDuergarWizardShip1 extends Enemy
{
protected int counter = 0;
protected int dd = 10;
public EnemyDuergarWizardShip1(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename,30,aiengine);
	setdy(0);
	setdx(0);
}

public void  move()
{
	if (counter++ > 160) {
		setdy(-5);
		super.move();
		return;
	}
	double d = distance(getx(),40*dd,gety(),dd);
	double r = Math.random();
	if (r >= 0.2) {
		setdx(-1);
	}
	if (r >= 0.4) {
		setdx(1);
	}
	if (r >= 0.6) {
		setdy(-1);
	}
	if (r >= 0.8) {
		setdy(1);
	}
	if (d > 100) {
		if (dx < 0)
			setdx(3);
		else
			setdx(-3);
		if (dy < 0)
			setdy(3);
		else 
			setdy(-3);
	}


	super.move(); 
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class EnemyHippo extends Enemy
{
public EnemyHippo(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename, 6,aiengine);
	setdx(0);
	setdy(0);
	imgs = new StateImageLibrary();
	addImage("basilisk200x150-1.png");
}

public void  move()
{
}
};




package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;
import java.util.Observable;
import java.util.Observer;

public class Enemy extends Entity implements Observer 
{

protected int hitpoints = 10;
protected AIengine aiengine;
public Enemy(int startx, int starty, String filename, int hp, AIengine aie)
{
	super(startx, starty, filename);
	hitpoints = hp;
	aiengine = aie;
        aiengine.addObserver(this);
}

public int hit(Player player)
{
	return --hitpoints;
}

public void  shoot(LinkedList<Bullet> l, Player player)
{
	//subclass resp
}
public void  shootenemy(LinkedList<Enemy> l, Player player)
{
	//subclass resp
}

public void message(String message)
{}
public void message(AIengine aiengine)
{}

public void update (Observable obj, Object arg) {
        if (arg instanceof String) {
            String resp = (String) arg;
            System.out.println("\nReceived Response: "+ resp );
        }
} 


};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class EnemyMech1 extends Enemy
{

public EnemyMech1(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename, 6,aiengine);
	setdx(-3);
	setdy(0);
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class EnemyPowerup1 extends Enemy
{
public EnemyPowerup1(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename, 10,aiengine);
	setdx(0);
	setdy(2);
}

public int hit(Player player)
{

	/////player = new PlayerLevel1Powerup1(player.getx(),player.gety());

	return -1;
}

};


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;
/*
* 2 bullets on the X/-Y diagonal
*/
public class EnemyProbe2 extends EnemyProbe
{
protected Player player;
public EnemyProbe2(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename,aiengine);
	setdy(+3);
	setdx(0);
}

public void move()
{
	if (player.getx() > getx())
		setdx(+1);
	else if (player.getx() < getx())
		setdx(-1);
	if (player.gety() > gety())
		setdy(+1);
	else if (player.gety() < gety())
		setdy(-1);
	super.move();
}

public void  shoot(LinkedList<Bullet> bullets, Player p)
{
	player = p;
	shootcounter += 1;
	if (shootcounter > 50) {
    		Bullet b1 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b2 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b3 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b4 = new Bullet(getx(),gety(), "bullet16x16-1.png");
		b1.setdy(-3);	
		b2.setdy(3);	
		b3.setdy(-3);	
		b4.setdy(3);	
		b1.setdx(-3);	
		b2.setdx(3);	
		b3.setdx(-3);	
		b4.setdx(3);	
		bullets.add(b1);
		bullets.add(b2);
		bullets.add(b3);
		bullets.add(b4);
		shootcounter = 0;
	}
}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;
/*
* 4 bullets diagonally
*/
public class EnemyProbe3 extends EnemyProbe2
{
public EnemyProbe3(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename,aiengine);
	setdy(+3);
	setdx(0);
}

public void  shoot(LinkedList<Bullet> bullets, Player p)
{
	player = p;
	shootcounter += 1;
	if (shootcounter > 50) {
    		Bullet b1 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b2 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b3 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b4 = new Bullet(getx(),gety(), "bullet16x16-1.png");
		b1.setdy(-3);	
		b2.setdy(-3);	
		b3.setdy(3);	
		b4.setdy(3);	
		b1.setdx(-3);	
		b2.setdx(3);	
		b3.setdx(3);	
		b4.setdx(-3);	
		bullets.add(b1);
		bullets.add(b2);
		bullets.add(b3);
		bullets.add(b4);
		shootcounter = 0;
	}
}
};


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;
/*
* 4 bullets squared 
*/
public class EnemyProbe4 extends EnemyProbe2
{
public EnemyProbe4(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename,aiengine);
	setdy(+3);
	setdx(0);
	imgs = new StateImageLibrary(); 
	addImage("shipprobe50x50-1.png");
	addImage("shipprobe50x50-2.png");
	addImage("shipprobe50x50-3.png");
	addImage("shipprobe50x50-4.png");
	addImage("shipprobe50x50-5.png");
	addImage("shipprobe50x50-6.png");
	addImage("shipprobe50x50-7.png");
	addImage("shipprobe50x50-8.png");
	addImage("shipprobe50x50-9.png");
	addImage("shipprobe50x50-10.png");
	addImage("shipprobe50x50-11.png");
	addImage("shipprobe50x50-12.png");
	addImage("shipprobe50x50-13.png");
	addImage("shipprobe50x50-14.png");
	addImage("shipprobe50x50-15.png");
	addImage("shipprobe50x50-16.png");
	addImage("shipprobe50x50-17.png");
	addImage("shipprobe50x50-18.png");
	addImage("shipprobe50x50-19.png");
	addImage("shipprobe50x50-20.png");
	addImage("shipprobe50x50-21.png");
	addImage("shipprobe50x50-22.png");
	addImage("shipprobe50x50-23.png");
	addImage("shipprobe50x50-24.png");
	hitpoints = 10;
}

public void  shoot(LinkedList<Bullet> bullets, Player p)
{
	player = p;
	shootcounter += 1;
	if (shootcounter > 50) {
    		Bullet b1 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b2 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b3 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b4 = new Bullet(getx(),gety(), "bullet16x16-1.png");
		b1.setdy(-3);	
		b1.setdx(0);	
		b2.setdy(0);	
		b2.setdx(3);	
		b3.setdy(3);	
		b3.setdx(0);	
		b4.setdy(0);	
		b4.setdx(-3);	
		bullets.add(b1);
		bullets.add(b2);
		bullets.add(b3);
		bullets.add(b4);
		shootcounter = 0;
	}
}
};



package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;
/*
* 4 bullets squared 
*/
public class EnemyProbe5 extends EnemyProbe4
{
public EnemyProbe5(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename,aiengine);
	setdy(+3);
	setdx(0);
	imgs = new StateImageLibrary(); 
	addImage("shipprobe50x50-1.png");
	addImage("shipprobe50x50-2.png");
	addImage("shipprobe50x50-3.png");
	addImage("shipprobe50x50-4.png");
	addImage("shipprobe50x50-5.png");
	addImage("shipprobe50x50-6.png");
	addImage("shipprobe50x50-7.png");
	addImage("shipprobe50x50-8.png");
	addImage("shipprobe50x50-9.png");
	addImage("shipprobe50x50-10.png");
	addImage("shipprobe50x50-11.png");
	addImage("shipprobe50x50-12.png");
	addImage("shipprobe50x50-13.png");
	addImage("shipprobe50x50-14.png");
	addImage("shipprobe50x50-15.png");
	addImage("shipprobe50x50-16.png");
	addImage("shipprobe50x50-17.png");
	addImage("shipprobe50x50-18.png");
	addImage("shipprobe50x50-19.png");
	addImage("shipprobe50x50-20.png");
	addImage("shipprobe50x50-21.png");
	addImage("shipprobe50x50-22.png");
	addImage("shipprobe50x50-23.png");
	addImage("shipprobe50x50-24.png");
	hitpoints = 10;
}

public void  shoot(LinkedList<Bullet> bullets, Player p)
{
	player = p;
	shootcounter += 1;
	if (shootcounter > 50) {
	if (Math.random() > 0.5) {
    		Bullet b1 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b2 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b3 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b4 = new Bullet(getx(),gety(), "bullet16x16-1.png");
		b1.setdy(-3);	
		b1.setdx(0);	
		b2.setdy(0);	
		b2.setdx(3);	
		b3.setdy(3);	
		b3.setdx(0);	
		b4.setdy(0);	
		b4.setdx(-3);	
		bullets.add(b1);
		bullets.add(b2);
		bullets.add(b3);
		bullets.add(b4);
	} else {
    		Bullet b1 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b2 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b3 = new Bullet(getx(),gety(), "bullet16x16-1.png");
    		Bullet b4 = new Bullet(getx(),gety(), "bullet16x16-1.png");
		b1.setdy(-3);	
		b1.setdx(-3);	
		b2.setdy(3);	
		b2.setdx(3);	
		b3.setdy(-3);	
		b3.setdx(3);	
		b4.setdy(3);	
		b4.setdx(-3);	
		bullets.add(b1);
		bullets.add(b2);
		bullets.add(b3);
		bullets.add(b4);
	}
		shootcounter = 0;
	}
}
};




package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class EnemyProbe extends Enemy
{
protected int shootcounter = 0;
public EnemyProbe(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename,2,aiengine);
	setdy(+3);
	setdx(0);
}

public void  move()
{
	super.move();
}

public void  shoot(LinkedList<Bullet> bullets, Player player)
{
	shootcounter += 1;
	if (shootcounter > 50) {
    		bullets.add(new BulletTargetted(getx(),gety(), "bullet16x16-1.png",player.getx(),player.gety(),2.0));
		shootcounter = 0;
	}
}
};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class EnemyRocket extends Bullet 
{
protected int shootcounter = 0;
protected int playerx, playery;
protected double bulletspeed = 1;
protected int targetted = 0;

public EnemyRocket(int startx, int starty, String filename, int px, int py, double bspd)
{
	super(startx, starty, filename);
	playerx = px;
	playery = py;

	bulletspeed = bspd;
	targetted = 0;
	setdx(0);
	setdy(+4);
}

public void movetargetted() 
{
	if (playerx == 0)
		playerx = 1;
	if (playery == 0)
		playery = 1;

	double ricox,ricoy;
	ricox = (double)Math.abs(playerx-getx());
	ricoy = (double)Math.abs(playery-gety());

	if (playerx <= getx() && playery <= gety()) {
		dx2 = - Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 = - Math.abs(playery-gety())/(ricox/ricoy);
	}
	else if (playerx >= getx() && playery <= gety()) {
		dx2 =   Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 = - Math.abs(playery-gety())/(ricox/ricoy);
	}
	else if (playerx <= getx() && playery >= gety()) {
		dx2 = - Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 =   Math.abs(playery-gety())/(ricox/ricoy);
	}
	else if (playerx >= getx() && playery >= gety()) {
		dx2 =   Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 =   Math.abs(playery-gety())/(ricox/ricoy);
	}
	dx2 *= (double)(bulletspeed/distance(playerx,getx(),playery,gety()));
	dy2 *= (double)(bulletspeed/distance(playerx,getx(),playery,gety()));
}

public void  move()
{

	targetted++;

	if (targetted == 40) {
		movetargetted();
		setdx(0);
		setdy(0);
	}
	else if (targetted > 40) {

		if (dx2 != 0) {
			x += (int)(dx2);
		}
		if (dy2 != 0) {
			y += (int)(dy2);
		}
	} else {
		super.move();
	}
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class EnemyScoutShip extends Enemy
{
public EnemyScoutShip(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename, 10, aiengine);
	setdy(8);
	setdx(-8);
	w = 50;
	h = 50;
}

public void  shoot(LinkedList<Bullet> bullets, Player player)
{}

public int hit(Player player)
{
	return -2; //return --hitpoints;
}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;
import java.util.Observable;
import java.util.Observer;

public class EnemySinus2 extends Enemy
{

protected double theta = 0.0;

public EnemySinus2(int startx, int starty, String filename, int hp, AIengine aie)
{
	super(startx, starty, filename,hp,aie);
	setdx(-3);
}

public void  move()
{
	theta += 0.1;
	y += -Math.sin(theta)*10;
	move2();	
}

public void  move2()
{
	if (dx != 0)
		x += dx;
	if (dy != 0)
		y += dy;
}
};


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;
import java.util.Observable;
import java.util.Observer;

public class EnemySinus extends Enemy
{

protected double theta = 0.0;

public EnemySinus(int startx, int starty, String filename, int hp, AIengine aie)
{
	super(startx, starty, filename,hp,aie);
}

public void  move()
{
	theta += 0.1;
	x += -Math.sin(theta)*10;
	y += -Math.sin(theta)*10;
	
	//move2();
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

public class EnemySnake1 extends Enemy
{
protected int jumpcounter = 0;
protected String direction = "up";
public EnemySnake1(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename, 6,aiengine);
	setdx(0);
	setdy(0);
	imgs = new StateImageLibrary();
	addImage("snake75x100-01.png");
	addImage("snake75x100-01.png");
	addImage("snake75x100-02.png");
	addImage("snake75x100-02.png");
	addImage("snake75x100-03.png");
	addImage("snake75x100-03.png");
	addImage("snake75x100-04.png");
	addImage("snake75x100-04.png");
	addImage("snake75x100-05.png");
	addImage("snake75x100-05.png");
	addImage("snake75x100-06.png");
	addImage("snake75x100-06.png");
	addImage("snake75x100-05.png");
	addImage("snake75x100-05.png");
	addImage("snake75x100-04.png");
	addImage("snake75x100-04.png");
	addImage("snake75x100-03.png");
	addImage("snake75x100-03.png");
	addImage("snake75x100-02.png");
	addImage("snake75x100-02.png");
}

public void  move()
{
	x -= 2;	
	
	if (direction == "up") {

		if (jumpcounter++ < 10) {
			y -= 7;
		} else if (jumpcounter > 10) {
			y -= 7;
			direction = "down";
		} 
	} else if (direction == "down") {
		y += 7;
		jumpcounter--;
		if (jumpcounter <= 0) {
			direction = "up";
		}
	}
}
};


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;
import java.util.Observable;
import java.util.Observer;

public class EnemySnakeHeadLeft extends Enemy
{
protected String prefix = "./pics/";
protected int shootcounter = 0;
protected Image shootimage;
public EnemySnakeHeadLeft(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename, 8,aiengine);
	setdx(0);
	setdy(0);
	imgs = new StateImageLibrary();
	addImage("snakehead150x100-left-1.png");
	shootimage = new ImageIcon(prefix+"snakehead150x100-left-shoot-1.png").getImage();
}

public void  move()
{}

public void shoot(LinkedList<Bullet> bullets, Player player)
{
	shootcounter += 1;
	if (shootcounter > 40) {
		System.out.println("foo");
    		bullets.add(new BulletSnakeHead(getx(),gety()+20, "bullet24x24-3.png"));
		shootcounter = 0;
	}
}

public Image getImage()
{
	if (shootcounter % 40 > 35 || shootcounter % 40 < 5) {
		return shootimage; 
	}
	return imgs.getImage();
}
};




package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class EnemyStealth extends Enemy
{
protected int shootcounter = 0;
public EnemyStealth(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename,3,aiengine);
	setdy(+6);
	setdx(0);
}

public void  move()
{
	super.move();
}

public void  shoot(LinkedList<Bullet> bullets, Player player)
{
	shootcounter += 1;
	if (shootcounter > 180) {
    		bullets.add(new BulletTargetted(getx(),gety(), "bullet16x16-1.png",player.getx(),player.gety(),3));
		shootcounter = 0;
	}
}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;
import java.util.Observable;
import java.util.Observer;

public class EnemyTailBeast extends Enemy
{
private double t = 0.0;
private double P0x,P0y,P1x,P1y,P2x,P2y;
private double prevx,prevy,prevx2,prevy2,prevx3,prevy3;
public EnemyTailBeast(int startxx, int startyy, String filename, int hp, AIengine aie)
{
	super(startxx, startyy, filename,hp,aie);
	P0x = 100;
	P0y = 500;
	P1x = 400;
	P1y = 100;
	P2x = 800;
	P2y = 500;

}

public void  move()
{
	if (t < 1)
		t += 0.01;

	x = (int)( (1-t)*(1-t)*P0x+2*(1-t)*t*P1x+t*t*P2x);
	y = (int)( (1-t)*(1-t)*P0y+2*(1-t)*t*P1y+t*t*P2y);
	
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class EnemyTargetted extends Enemy
{
protected int counter = 0;
protected int playerx, playery;
protected double speed = 1;
protected int shootcounter = 0;
public EnemyTargetted(int startx, int starty, String filename, int px, int py, double spd, AIengine aiengine)
{
	super(startx, starty, filename,2,aiengine);
	
	speed = (double)spd;

	playerx = px;
	playery = py;

	if (playerx == 0)
		playerx = 1;
	if (playery == 0)
		playery = 1;

	double ricox,ricoy;
	ricox = (double)Math.abs(playerx-getx());
	ricoy = (double)Math.abs(playery-gety());

	if (playerx <= getx() && playery <= gety()) {
		dx2 = - Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 = - Math.abs(playery-gety())/(ricox/ricoy);
	}
	else if (playerx >= getx() && playery <= gety()) {
		dx2 =   Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 = - Math.abs(playery-gety())/(ricox/ricoy);
	}
	else if (playerx <= getx() && playery >= gety()) {
		dx2 = - Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 =   Math.abs(playery-gety())/(ricox/ricoy);
	}
	else if (playerx >= getx() && playery >= gety()) {
		dx2 =   Math.abs(playerx-getx())/(ricox/ricoy);
		dy2 =   Math.abs(playery-gety())/(ricox/ricoy);
	}
	dx2 *= (double)(speed/distance(playerx,getx(),playery,gety()));
	dy2 *= (double)(speed/distance(playerx,getx(),playery,gety()));
}

public void  move()
{
		if (dx2 != 0) {
			x += (int)(dx2/*-speed*/);
		}
		if (dy2 != 0) {
			y += (int)(dy2/*-speed*/);
		}
}

public void  shoot(LinkedList<Bullet> bullets, Player player)
{
	shootcounter += 1;
	if (shootcounter > 80) {
    		bullets.add(new BulletTargetted(getx(),gety(), "bullet16x16-1.png",player.getx(),player.gety(),3));
		shootcounter = 0;
	}
}
};


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class Entity 
{
protected int x,y,dx,dy,w,h;
protected double dx2=10.0, dy2=10.0;
protected StateImageLibrary imgs;
public Entity(int startx, int starty, String filename)
{
	imgs = new StateImageLibrary();
	x = startx;
	y = starty;
	dx = 0;
	dy = 0;
	addImage(filename);
}

public int getx()
{
	return x;
}

public int gety()
{
	return y;
}

public void addImage(String filename)
{
	imgs.addImage(filename);
}

public Image getImage()
{
	return imgs.getImage();
}

public void setdx(int dxx)
{
	dx = dxx;
}

public void setdy(int dyy)
{
	dy = dyy;
}

public void  move()
{
	if (dx != 0)
		x += dx;
	if (dy != 0)
		y += dy;
}

public double distance(int x1, int x2, int y1, int y2)
{
	return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

public boolean collision(Entity e, double mapx)
{
	if (distance(e.getx()-(int)mapx, x, e.gety(), y) < 20) {
		System.out.println("collision");	
		return true;
	}
	else
		return false;
}

public int getdx()
{
	return dx;
}

public int getdy()
{
	return dy;
}

public double getdx2()
{
	return dx2;
}

public double getdy2()
{
	return dy2;
}

};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.Timer;

import java.util.*;

public class Game extends JPanel implements ActionListener {
    String prefix = "./pics/";
    Dimension d;
    Font smallfont = new Font("Helvetica", Font.BOLD, 14);

    FontMetrics fmsmall, fmlarge;
    double mapy = 0;
    double mapx = 0;
    double activationPixel = 0;
    int levelnumber = 1;
    private int SCREENWIDTH = 800;
    private int SCREENHEIGHT = 600;
    private int spritecount = 3;
    Player player = new Player(400, 450);
    final static LinkedList<Enemy> enemies = new LinkedList<Enemy>();
    final static LinkedList<Bullet> bullets = new LinkedList<Bullet>();
    final static LinkedList<Bullet> friendlybullets = new LinkedList<Bullet>();
    final static LinkedList<Sprite> sprites = new LinkedList<Sprite>();
    final static LinkedList<Sprite> codecs = new LinkedList<Sprite>(); 
    static AIengine aiengine = new AIengine();
    static Room room;
    AIPlayerStateMove playerstate = new AIPlayerStateMove(levelnumber,0);
 
    final int blocksize = 60;
    final int mapw = 13;
    final int maph = 10;
    final int nrofblocks = 13;
    final int scrsize = nrofblocks;//NOTE* blocksize;
    Image bg1,bg2,bg3, tile1, tile2, tile3, explosion1;
    final short leveldata[] =
    { 
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  1,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
    };
    final short leveldata2[] =
    { 
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 1 , 1,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
      0, 0 , 0,  0,  0,  0,  0,  0,  0,  0,  0, 0, 0,  
    };
    short[] screendata;
    Timer timer;
    LevelStateLevel levelstate = new LevelStateLevel(levelnumber);

    public Game() {

        GetImages();
	room = new Room1(enemies,aiengine);
    	//enemies.add(new EnemyPowerup1(0,0, "powerup64x64-1.png", aiengine));
    	//enemies.add(new EnemyRocket(10,10, "rocket20x20-1.png", player.getx(),player.gety(),8,aiengine));
    	//bullets.add(new BulletTargetted(300,100, "bullet16x16-1.png",100,200));
	//bullets.get(0).setdx(-2);
        addKeyListener(new TAdapter());
        screendata = new short[nrofblocks * nrofblocks];
//        mazecolor = new Color(5, 100, 5);
        setFocusable(true);

        d = new Dimension(800, 600);
    	//player = playerstate.initPlayer(0,400,400);
	player.setFriendlyBullets(friendlybullets);
        setBackground(Color.black);
        setDoubleBuffered(true);
        timer = new Timer(40, this);
        timer.start();

	levelstate.setData(enemies,sprites,aiengine, room, codecs,spritecount);
	//AIPlayerStateMove playerstate = new AIPlayerStateMove(levelnumber);
    //Thread thread = new Threa(aiengine);
    //thread.start();   
        	
    }



    public void addNotify() {
        super.addNotify();
        GameInit();
    }

    public void DrawPlayer(Graphics2D g2d) {
           g2d.drawImage(player.getImage(), player.getx(), player.gety(), this);
    }
    public void DrawEnemy(Graphics2D g2d, Enemy enemy) {//NOTE1: -mapx only use
           g2d.drawImage(enemy.getImage(), enemy.getx()-(int)mapx, enemy.gety(), this);
    }

    public void DrawEnemies(Graphics2D g2d) {
	for (int i= 0; i < enemies.size(); i++) 
		DrawEnemy(g2d, enemies.get(i));
    }
    public void MoveEnemies() {
	for (int i= 0; i < enemies.size(); i++) {
		if (enemies.get(i).getx() > SCREENWIDTH || enemies.get(i).gety() > SCREENHEIGHT) {
			enemies.remove(i);
		}
		enemies.get(i).move();
	}
    }
    public void MoveEnemiesLevel2() {
	for (int i= 0; i < enemies.size(); i++) {
		if (enemies.get(i).gety() > SCREENHEIGHT) {
			enemies.remove(i);
		}
		enemies.get(i).move();
	}
    }
    public void EnemiesShoot(LinkedList<Bullet> bullets) {
	for (int i= 0; i < enemies.size(); i++) 
		enemies.get(i).shoot(bullets,player);
    }
    public void EnemiesShootEnemies(LinkedList<Enemy> enemies) {
	for (int i= 0; i < enemies.size(); i++) 
		enemies.get(i).shootenemy(enemies,player);
    }
    public void SpritesShoot(LinkedList<Bullet> bullets) {
	for (int i= 0; i < sprites.size(); i++) 
		sprites.get(i).shoot(bullets,player);
    }
    public void SpritesShootEnemies(LinkedList<Enemy> enemies) {
	for (int i= 0; i < sprites.size(); i++) 
		sprites.get(i).shootenemy(enemies,player);
    }
    public void DrawSprites(Graphics2D g2d) {
	for (int i= 0; i < sprites.size(); i++) 
		DrawSprite(g2d, sprites.get(i));
    }
    public void MoveSprites() {
	for (int i= 0; i < sprites.size(); i++) {
		if (sprites.get(i).getx() > SCREENWIDTH || sprites.get(i).gety() > SCREENHEIGHT) {
			sprites.remove(i);
		}
		sprites.get(i).move();
	}
    }
    public void DrawSprite(Graphics2D g2d, Sprite sprite) {
           g2d.drawImage(sprite.getImage(), sprite.getx(), sprite.gety(), this);
    }    
    public void DrawBullet(Graphics2D g2d, Bullet bullet) {
           g2d.drawImage(bullet.getImage(), bullet.getx(), bullet.gety(), this);
    }
    public void DrawBulletLevel2(Graphics2D g2d, Bullet bullet) {
           g2d.drawImage(bullet.getImage(), bullet.getx() - (int)mapx, bullet.gety(), this);
    }

    public void DrawCodecs(Graphics2D g2d) {
	for (int i= 0; i < codecs.size(); i++) 
		DrawSprite(g2d, codecs.get(i));
    }
    public void DrawBullets(Graphics2D g2d) {
	for (int i= 0; i < bullets.size(); i++) 
		DrawBullet(g2d, bullets.get(i));
    }
    public void DrawBulletsLevel2(Graphics2D g2d) {
	for (int i= 0; i < bullets.size(); i++) 
		DrawBulletLevel2(g2d, bullets.get(i));
    }
    public void MoveBullets() {
	for (int i= 0; i < bullets.size(); i++) {
		bullets.get(i).move();
		if (bullets.get(i).getx() > SCREENWIDTH || bullets.get(i).gety() > SCREENHEIGHT) {
			bullets.remove(i);
		}
	}
    }
    public void MoveBulletsLevel2() {
	for (int i= 0; i < bullets.size(); i++) {
		bullets.get(i).move();
		if (bullets.get(i).gety() > SCREENHEIGHT) {
			bullets.remove(i);
		}
	}
    }
    public void DeleteBullets() {
	for (int i= 0; i < bullets.size(); i++) {
		if (bullets.get(i).getdx2() < 0.2 || bullets.get(i).getdy2() < 0.2) {
			bullets.remove(i);
		}
	}
    }
    public void DrawFriendlyBullets(Graphics2D g2d) {
	for (int i= 0; i < friendlybullets.size(); i++) 
		DrawBullet(g2d, friendlybullets.get(i));
    }
    public void MoveFriendlyBullets() {
	for (int i= 0; i < friendlybullets.size(); i++) 
		friendlybullets.get(i).move();
    }

    public void DoCollision(Graphics2D g2d) {
	boolean flag = false;
	for (int i= 0; i < enemies.size(); i++) 
		for (int j= 0; j < friendlybullets.size(); j++) 
			if (friendlybullets.get(j).collision(enemies.get(i),mapx)) {
				friendlybullets.remove(j);
				DrawExplosion(g2d, enemies.get(i).getx()-(int)mapx,enemies.get(i).gety());
				int ret = enemies.get(i).hit(player);
				if (ret == 0) 
					enemies.remove(i);
				else if (ret == -1) {//NOTE: 1st powerup
					enemies.remove(i);
					player = new PlayerLevel1Powerup1(player.getx(),player.gety());
					player.setFriendlyBullets(friendlybullets);
				} else if (ret == -2) {//NOTE: fly under
					spritecount--;//NOTE
					enemies.remove(i);
					flag = true;
				}
			}
	if (flag) {
		levelstate.setData(enemies,sprites,aiengine,room,codecs,spritecount);
	}
    }

    public void DoCollisionPlayer() {
	for (int i= 0; i < enemies.size(); i++) 
		if (player.collision(enemies.get(i))) {
			enemies.remove(i);
		}
	for (int i= 0; i < bullets.size(); i++) 
		if (player.collision(bullets.get(i))) {
			bullets.remove(i);
		}
    }

    public int CollisionLadderLevel2() {
	if (mapx > 1350 && player.gety() < 250) {
		System.out.println("**********mapx="+mapx);
		return 1;
	} else {
		return 0;
	}
    }
    public int CollisionLadderLevel2ToLevel3() {
	if (player.gety() < 10) {
		System.out.println("Loading level 3 (2.2)");
		return 1;
	} else {
		return 0;
	}
    }
    public void DoCollisionPlayerLevel2() {
	for (int i= 0; i < enemies.size(); i++) 
		if (((PlayerLevel2)player).collisionLevel2(enemies.get(i),(int)mapx)) {
			enemies.remove(i);
		}
	for (int i= 0; i < bullets.size(); i++) 
		if (((PlayerLevel2)player).collisionLevel2(bullets.get(i),(int)mapx)) {
			bullets.remove(i);
		}
    }
    public void DoCollisionPlayerLevel3() {
	for (int i= 0; i < enemies.size(); i++) 
		if (((PlayerLevel3)player).collisionLevel3(enemies.get(i),(int)mapx)) {
			enemies.remove(i);
		}
	for (int i= 0; i < bullets.size(); i++) 
		if (((PlayerLevel3)player).collisionLevel3(bullets.get(i),(int)mapx)) {
			bullets.remove(i);
		}
    }


    public void DrawExplosion(Graphics2D g2d, int xx,int yy) {
        g2d.drawImage(explosion1, xx, yy, this);
    }
    public void DrawBackground(Graphics2D g2d) {
        g2d.drawImage(bg1, 0, (int)activationPixel, this);
    }
    /*public void DrawBackground4(Graphics2D g2d) {
        g2d.drawImage(bg4, (int)activationPixel, 0, this);
    }*/
    public void DrawBackground2(Graphics2D g2d) {
        g2d.drawImage(bg2, (int)(-mapx), 0, this);
    }
    public void DrawBackground3(Graphics2D g2d) {
        g2d.drawImage(bg3, (int)(-mapx), 0, this);
    }
    public void DrawMapUp(Graphics2D g2d) {
        int i = 0;
        int x, y;
        for (y = 0+(int)mapy; y < maph+(int)mapy+1; y++) {
            for (x = 0; x < mapw; x++) {
//                g2d.setColor(mazecolor);
                g2d.setStroke(new BasicStroke(2));

                if (leveldata[y*mapw+x] == 0) // draws left
                {
            		//nothing g2d.drawImage(tile1, x*60, i*60 + (int)activationPixel%60 , this);
                }
                else if (leveldata[y*mapw+x] == 1) // draws left
                {
            		g2d.drawImage(tile1, x*60, i*60 + (int)activationPixel%60 , this);
                }
                else if (leveldata[y*mapw+x] == 2) // draws left
                {
            		g2d.drawImage(tile2, x*60, i*60 + (int)activationPixel%60 , this);
                }
            }
	i += 1;
        }
        activationPixel -= 1;
	if (activationPixel%60 == 0 && activationPixel < 0)
        	mapy += 1;
    }

    public void DrawMapRight(Graphics2D g2d) {
        int i = 0;
        int x, y;
//                g2d.setColor(mazecolor);
                g2d.setStroke(new BasicStroke(2));

        for (y = 0+(int)mapy; y < maph+(int)mapy+1; y++) {
            for (x = 0; x < mapw; x++) {
                if (leveldata2[y*mapw+x] == 0) // draws left
                {
            		//nothing g2d.drawImage(tile1, x*60, i*60 + (int)activationPixel%60 , this);
                }
                else if (leveldata2[y*mapw+x] == 1) // draws left
                {
            		g2d.drawImage(tile1, i*60 + (int)activationPixel%60 , x*60, this);
                }
            }
	i += 1;
        }
        activationPixel -= 1;
	if (activationPixel%60 == 0 && activationPixel < 0)
        	mapy += 1;
    }

    public void GameInit() {
        LevelInit();
    }


    public void LevelInit() {
        int i;
        for (i = 0; i < nrofblocks * nrofblocks; i++)
            screendata[i] = leveldata[i];

    }


    public void GetImages()
    {
      
      explosion1 = new ImageIcon(prefix+"explosion48x35-1.png").getImage();//prefix+"ghost.png")).getImage();
      tile1 = new ImageIcon(prefix+"tile60x60-1.png").getImage();//prefix+"ghost.png")).getImage();
      tile2 = new ImageIcon(prefix+"tile60x60-2.png").getImage();//prefix+"ghost.png")).getImage();
      bg1 = new ImageIcon(prefix+"bg800x1200-1.png").getImage();//prefix+"ghost.png")).getImage();
      //bg2 = new ImageIcon(prefix+"bg1200x800-2.png").getImage();//prefix+"ghost.png")).getImage();
      bg2 = new ImageIcon(prefix+"bg4000x600-3.png").getImage();//prefix+"ghost.png")).getImage();
      bg3 = new ImageIcon(prefix+"bg4000x600-4.png").getImage();//prefix+"ghost.png")).getImage();
      //player = new ImageIcon(Board.class.getResource("/Users/roguelord/java/2d/shooter/pics/ghost.png")).getImage();//prefix+"ghost.png")).getImage();

    }

    public void paint(Graphics g)
    {
      super.paint(g);

      Graphics2D g2d = (Graphics2D) g;

      g2d.setColor(Color.black);
      g2d.fillRect(0, 0, d.width, d.height);

      levelstate.eventloop(g2d); 

      if (levelnumber == 1) {
      DeleteBullets();
      player.move();
      EnemiesShoot(bullets);
      EnemiesShootEnemies(enemies);
      DrawBackground(g2d);
      DrawMapUp(g2d);
      DrawSprites(g2d);
      SpritesShoot(bullets);
      SpritesShootEnemies(enemies);
      MoveSprites();
      DrawFriendlyBullets(g2d);
      MoveFriendlyBullets();
      DrawBullets(g2d);
      MoveBullets();
      DrawEnemies(g2d);
      MoveEnemies();
      DrawPlayer(g2d);
      DrawCodecs(g2d);
      DoCollision(g2d); 
      DoCollisionPlayer(); 
      Toolkit.getDefaultToolkit().sync();
      g.dispose();
      }
      if (levelnumber == 2) {
      EnemiesShoot(bullets);
      EnemiesShootEnemies(enemies);
      player.move();
      ((PlayerLevel2)player).fall();
      DrawBackground2(g2d);
      DrawFriendlyBullets(g2d);
      MoveFriendlyBullets();
      DrawBulletsLevel2(g2d);
      MoveBulletsLevel2();
      DrawEnemies(g2d);
      MoveEnemiesLevel2();
      DrawPlayer(g2d);
      DoCollision(g2d); 
      DoCollisionPlayerLevel2(); 
      Toolkit.getDefaultToolkit().sync();
      g.dispose();

      }
      if (levelnumber == 3) {
      EnemiesShoot(bullets);
      EnemiesShootEnemies(enemies);
      player.move();
      ((PlayerLevel3)player).fall();
      DrawBackground3(g2d);
      DrawFriendlyBullets(g2d);
      MoveFriendlyBullets();
      DrawBulletsLevel2(g2d);
      MoveBulletsLevel2();
      DrawEnemies(g2d);
      MoveEnemiesLevel2();
      DrawPlayer(g2d);
      DoCollision(g2d); 
      DoCollisionPlayerLevel3(); 
      Toolkit.getDefaultToolkit().sync();
      g.dispose();
	}
      if (levelnumber == 4) {
      DeleteBullets();
      player.move();
      EnemiesShoot(bullets);
      EnemiesShootEnemies(enemies);
      DrawBackground2(g2d);
      DrawMapRight(g2d);
      DrawSprites(g2d);
      SpritesShoot(bullets);
      SpritesShootEnemies(enemies);
      MoveSprites();
      DrawFriendlyBullets(g2d);
      MoveFriendlyBullets();
      DrawBullets(g2d);
      MoveBullets();
      DrawEnemies(g2d);
      MoveEnemies();
      DrawPlayer(g2d);
      DrawCodecs(g2d);
      DoCollision(g2d); 
      DoCollisionPlayer(); 
      Toolkit.getDefaultToolkit().sync();
      g.dispose();
      
	}
    }

    class TAdapter extends KeyAdapter {
        public void keyReleased(KeyEvent e) {
        } 
      
        public void keyPressed(KeyEvent e) {

          int key = e.getKeyCode();

	   if (key == KeyEvent.VK_N) {

    		enemies.removeAll(enemies);
    		bullets.removeAll(bullets);
    		friendlybullets.removeAll(friendlybullets);
    		sprites.removeAll(sprites);
    		codecs.removeAll(codecs);
    		aiengine = new AIengine();

		playerstate = new AIPlayerStateMove(++levelnumber,0);
		player = playerstate.initPlayer(0,player.getx(),player.gety());
		player.setFriendlyBullets(friendlybullets);
    		levelstate = new LevelStateLevel(levelnumber);
		levelstate.setData(enemies,sprites,aiengine, 
					room, codecs,spritecount);
	        	
	   } else {
		player.setKey(key);
		playerstate.move(player);
		if (/*player.getx() >= 394 && FIXME1*/levelnumber == 2 && key != KeyEvent.VK_F)//FIXME 
		{
			if (key != KeyEvent.VK_UP && key != KeyEvent.VK_DOWN/*NOTE ladders*/) {
				if (CollisionLadderLevel2() != 1) {
					if (key == KeyEvent.VK_RIGHT) {
						mapx += 10.0;
						levelstate.setMapX(mapx);
					}
					else if (key == KeyEvent.VK_LEFT) {
						mapx -= 10.0;
						levelstate.setMapX(mapx);
					}
				}
			} else if (key == KeyEvent.VK_UP) {
				System.out.println("UP key pressed");
				if (CollisionLadderLevel2() == 1) {
				System.out.println("on ladder....");
					playerstate = new AIPlayerStateMove(levelnumber,4);
					player = playerstate.initPlayer(4,player.getx(),player.gety());
					player.setFriendlyBullets(friendlybullets);
				} 
				if (CollisionLadderLevel2ToLevel3() == 1) {
    					enemies.removeAll(enemies);
    					bullets.removeAll(bullets);
    					friendlybullets.removeAll(friendlybullets);
    					sprites.removeAll(sprites);
    					codecs.removeAll(codecs);
    					aiengine = new AIengine();
					playerstate = new AIPlayerStateMove(++levelnumber,0);
					player = playerstate.initPlayer(0,player.getx(),player.gety());
					player.setFriendlyBullets(friendlybullets);
    					levelstate = new LevelStateLevel(levelnumber);
					levelstate.setData(enemies,sprites,aiengine, 
					room, codecs,spritecount);
					levelstate.setMapX(0);
					mapx = 0;
				}	
			}
			levelstate.setMapX(mapx);
		}
		System.out.println("mapx="+mapx);
		if (mapx == 700-400 && player instanceof PlayerLevel2Fall1) {
			playerstate = new AIPlayerStateMove(levelnumber,0);
			player = playerstate.initPlayer(0,player.getx(),player.gety());
			player.setFriendlyBullets(friendlybullets);

		}
		else if ((mapx == 700-400 && player instanceof PlayerLevel2) 
			||
			(mapx == 1000-400 && player instanceof PlayerLevel2Fall2)) 
		{
			System.out.println("*****************foo");
			playerstate = new AIPlayerStateMove(levelnumber,1);
			player = playerstate.initPlayer(1,player.getx(),player.gety());
			player.setFriendlyBullets(friendlybullets);
		} 
		else if (mapx == 1000-400) 
		{
			playerstate = new AIPlayerStateMove(levelnumber,2);
			player = playerstate.initPlayer(2,player.getx(),player.gety());
			player.setFriendlyBullets(friendlybullets);
		} else if (mapx == 1300-400) 
		{
			System.out.println("baz");
			playerstate = new AIPlayerStateMove(levelnumber,3);
			player = playerstate.initPlayer(3,player.getx(),player.gety());
			player.setFriendlyBullets(friendlybullets);
		}
	  }
	  /* if (levelnumber == 2) {
	  	int foo = player.movePWithKeyLevel2(key);
      		if (foo > 0 && player.getx() >= 394) {
			mapx+=5.0;
      		}
	  	player.shootP(key, friendlybullets);
	  }*/
	}
	}
    public void actionPerformed(ActionEvent e) {
        repaint();  
    }

}
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

import java.awt.Graphics2D;
import java.util.*;

interface LevelState
{
public void setData(LinkedList<Enemy> e, LinkedList<Sprite> s, AIengine aie, Room r, LinkedList<Sprite> c, int spritecnt);
public void eventloop(Graphics2D g2d);
public void setMapX(double mx);
}


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.Graphics2D;
import java.util.*;

public class LevelStateLevel1 implements LevelState 
{
private LinkedList<Enemy> enemies;
private LinkedList<Sprite> sprites;
private AIengine aiengine;
private int activationPixel = 0;//NOTE: doubled in class Game()
private Room room;
private LinkedList<Sprite> codecs;
private int spritecount = 3;

public void setData(LinkedList<Enemy> e, LinkedList<Sprite> s, AIengine aie, Room r, LinkedList<Sprite> c, int spritecnt)
{
	enemies = e;
	sprites = s;
	aiengine = aie;
	room = r;
	codecs = c;
	spritecount = spritecnt;
}

public void eventloop(Graphics2D g2d)
{
	activationPixel--;
      if (activationPixel == -10) {
	//test aiengine.messageEngine("123");
	room.addPart0(enemies,sprites,aiengine);
      } else if (activationPixel == -100) {
	room.addPart1(enemies,sprites,aiengine);
      } else if (activationPixel == -150) {
	room.addPart2(enemies,sprites,aiengine);
      } else if (activationPixel == -180) {
	room.addPart3(enemies,sprites,aiengine);
      } else if (activationPixel == -280) {
	room.addPart4(enemies,sprites,aiengine);
      }	else if (activationPixel == -380) {
	//room.addPart5(enemies,sprites,aiengine);//FIXME
		for (int i = 0; i < spritecount; i++) {
    			sprites.add(new SpriteScoutShip(10+i*100,400+112, "shipwhite24x24-1.png",aiengine));
		}
      }	else if (activationPixel == -500) {
	room.addPart6(enemies,sprites,aiengine);//FIXME
      } else if (activationPixel == -700) {
	//room.addPart7(enemies,sprites,aiengine);//FIXME
	for (int i = 0; i < spritecount; i++) {
    		Enemy e = new EnemyScoutShip(400+i*100,-112, "shipwhite50x50-1.png",aiengine);
    		enemies.add(e);
	}

      } else if (activationPixel == -750) {
		room.addPart8(enemies,sprites,aiengine);//FIXME
		Sprite s1 = new SpriteCodec1(0,400,"duergarcodec700x100-1.png",aiengine);
		codecs.add(s1);
      } else if (activationPixel == -850) {
		codecs.remove(0);//remove codec1
      } else if (activationPixel == -907) {
		room.addPart9(enemies,sprites,aiengine);//FIXME
      } else if (activationPixel == -927) {
    		//enemies.add(new EnemyDuergarSatteliteShip2(700,0, "shipaliengrey50x50-1.png", 4, aiengine));
    		//enemies.add(new EnemyDuergarSatteliteShip2(600,0, "shipaliengrey50x50-1.png", 4, aiengine));
      } else if (activationPixel == -947) {
		room.addPart10(enemies,sprites,aiengine);//FIXME
      } else if (activationPixel == -1030) {
		room.addPart11(enemies,sprites,aiengine);//FIXME
      }

}

public void setMapX(double mx)
{}
};




package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.Graphics2D;
import java.util.*;

public class LevelStateLevel2 implements LevelState
{

private LinkedList<Enemy> enemies;
private LinkedList<Sprite> sprites;
private AIengine aiengine;
private int activationPixel = 0;//NOTE: doubled in class Game()
private Room room;
private LinkedList<Sprite> codecs;
private int spritecount = 3;
private double mapx = 0;
private boolean enemyflag0 = false;
private boolean enemyflag1 = false;
private boolean enemyflag2 = false;
public void setData(LinkedList<Enemy> e, LinkedList<Sprite> s, AIengine aie, Room r, LinkedList<Sprite> c, int spritecnt)
{
	enemies = e;
	sprites = s;
	aiengine = aie;
	room = r;
	codecs = c;
	spritecount = spritecnt;
	//NOTE instanceof rooms
	if (room == null || (room instanceof Room1) || (room instanceof Room3))
		room = new Room2(enemies,aiengine);

}

public void eventloop(Graphics2D g2d)
{
	activationPixel--;
      //EXAMPLE : if (mapx > 10 && activationPixel % 100 == 0) -> returning enemies each 100 frames when over x-mapx
      if (mapx > 10 && !enemyflag0) {
		//test aiengine.messageEngine("123");
		enemyflag0 = true;
//		room.addPart0(enemies,sprites,aiengine);
       }
      else if (mapx == 200 && !enemyflag1) {
		enemyflag1 = true;
//		room.addPart1(enemies,sprites,aiengine);
		room.addPart0(enemies,sprites,aiengine);
       }
      else if (mapx == 500 && !enemyflag2) {
		enemyflag2 = true;
		room.addPart1(enemies,sprites,aiengine);
       }
	
}

public void setMapX(double mx)
{
	mapx = mx;
}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;
import java.awt.Graphics2D;

public class LevelStateLevel3 implements LevelState 
{
private LinkedList<Enemy> enemies;
private LinkedList<Sprite> sprites;
private AIengine aiengine;
private int activationPixel = 0;//NOTE: doubled in class Game()
private Room room;
private LinkedList<Sprite> codecs;
private int spritecount = 3;

public void setData(LinkedList<Enemy> e, LinkedList<Sprite> s, AIengine aie, Room r, LinkedList<Sprite> c, int spritecnt)
{
	enemies = e;
	sprites = s;
	aiengine = aie;
	room = r;
	codecs = c;
	spritecount = spritecnt;
	//NOTE instanceof rooms
	if (room == null || (room instanceof Room1) || (room instanceof Room2))
		room = new Room3(enemies,aiengine);
}

public void eventloop(Graphics2D g2d)
{
	activationPixel--;
      if (activationPixel == -10) {
	//test aiengine.messageEngine("123");
	room.addPart0(enemies,sprites,aiengine);
       }
      else if (activationPixel == -14) {
	room.addPart1(enemies,sprites,aiengine);
       }
      else if (activationPixel == -18) {
	room.addPart1(enemies,sprites,aiengine);
       }
      else if (activationPixel == -22) {
	room.addPart1(enemies,sprites,aiengine);
       }
      else if (activationPixel == -26) {
	room.addPart1(enemies,sprites,aiengine);
       }
      else if (activationPixel == -30) {
	room.addPart1(enemies,sprites,aiengine);
       }
}

public void setMapX(double mx)
{}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.Graphics2D;
import java.util.*;

public class LevelStateLevel 
{
private LevelState my_state;
public LevelStateLevel(int levelnumber) {
	if (levelnumber == 1)
		setState(new LevelStateLevel1());
	else if (levelnumber == 2)
		setState(new LevelStateLevel2());
	else if (levelnumber == 3)
		setState(new LevelStateLevel3());
}

public void setState(LevelState ns) {
	this.my_state = ns;
}

public void setData(LinkedList<Enemy> e, LinkedList<Sprite> s, AIengine aie, Room r, LinkedList<Sprite> c, int spritecnt)
{
	this.my_state.setData(e,s,aie,r,c,spritecnt);
}

public void eventloop(Graphics2D g2d) {
	this.my_state.eventloop(g2d);
}

public void setMapX(double mx)
{
	this.my_state.setMapX(mx);
}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class Player
{
int key;
static LinkedList<Bullet> friendlybullets;
protected int playerx, playery, playerw, playerh, dx, dy;
protected StateImageLibrary images = new StateImageLibrary();
String prefix = "./pics/";
Image playerimg;
protected int jumpcounter = 0;
public Player(int startx, int starty)
{
	playerx = startx;
	playery = starty;
	playerw = 64;
	playerh = 112;
	dx = 0;//5;
	dy = 0;//5;
	images.addImage("shiphighelf64x112-1.png");
}

public int getx()
{
	return playerx;
}

public int gety()
{
	return playery;
}

public Image getImage()
{
	return images.getImage();
}

public void movePWithKey(int key)
{

           if (key == KeyEvent.VK_LEFT)
            {
		if (dx!=0)	dx = 0;
		else dx = -5;
            }
            else if (key == KeyEvent.VK_RIGHT)
            {
		if (dx!=0) dx = 0;
		else dx = 5;
            }
            if (key == KeyEvent.VK_UP)
            {
		if (dy!=0) dy = 0; 
		else dy = -5;
            }
            else if (key == KeyEvent.VK_DOWN)
            {
		if (dy!=0) dy = 0;
		else dy = 5;
            }
}

public void move() 
{
	playerx += dx;
	playery += dy;
	if (playerx < dx)
		playerx = dx; 
	if (playerx > 800-dx-playerw)
		playerx = 800-dx-playerw; 
	if (playery < dy)
		playery = dy; 
	if (playery > 600-dy-playerh)
		playery = 600-dy-playerh; 
}



public void shootP(int key, LinkedList<Bullet> l)
{
            if (key == KeyEvent.VK_F)
            {
		Bullet bullet = new Bullet(getx()+12,gety(),"bullet24x24-1.png");
		bullet.setdy(-6);
		l.add(bullet);
            }
}

public double distance(int x1, int x2, int y1, int y2)
{
	return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
public boolean collision(Entity e)
{
	if (distance(e.getx(), playerx, e.gety(), playery) < 30) {
		System.out.println("collision with player...gameover.");
		System.exit(99);	
		return true;
	}
	else
		return false;
}
public int movePWithKeyLevel3(int k)
{
	//subclass resp
	return 0;
}
public int movePWithKeyLevel2(int k)
{
	//subclass resp
	return 0;
}

public void setFriendlyBullets(LinkedList<Bullet> l)
{
	friendlybullets = l;
}

public void moveP()
{
  	movePWithKey(key);
  	shootP(key, friendlybullets);
}

public void setKey(int k)
{
	key = k;
}
};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class PlayerLevel1Powerup1 extends Player
{
public PlayerLevel1Powerup1(int startx, int starty)
{

	super(startx, starty);

	//images = new StateImageLibrary();
	//images.addImage("playership50x50-1.png");
	//images.addImage("playership50x50-2.png");
}

public void shootP(int key, LinkedList<Bullet> l)
{
            if (key == KeyEvent.VK_F)
            {
		System.out.println("........");
		Bullet bullet1 = new Bullet(getx(),gety(),"bullet24x24-1.png");
		Bullet bullet2 = new Bullet(getx()+24,gety(),"bullet24x24-1.png");
		bullet1.setdy(-6);
		l.add(bullet1);
		bullet2.setdy(-6);
		l.add(bullet2);
            }
}

public void moveP()
{
  	movePWithKey(key);
  	shootP(key, friendlybullets);
}
};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class PlayerLevel2Fall1 extends PlayerLevel2
{
protected int jumpcounter2 = 11;
public PlayerLevel2Fall1(int startx, int starty)
{
	super(startx, starty);
}

public void fall()
{

	    if (jumpcounter > 0) {
	    	playery -= 3*jumpcounter++;
	   }
	   if (jumpcounter > 11) {
		jumpcounter2--;
		jumpcounter = 0;
	   }
	   if (jumpcounter2 == 0) {
		jumpcounter2 = 11;
	   }
	   if (playery <= 200 && jumpcounter == 0 && jumpcounter2 > 0) {
		playery = 200-1;
		return;
	    }
	   if (jumpcounter == 0 && jumpcounter2 > 0) {
		jumpcounter2--;
	   }
	   
		 playery += 3;

	    if (playery > 400)
		playery = 400-1;

}


};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class PlayerLevel2Fall2 extends PlayerLevel2
{
public PlayerLevel2Fall2(int startx, int starty)
{
	super(startx, starty);
}

};


package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class PlayerLevel2Fall3 extends PlayerLevel2
{
public PlayerLevel2Fall3(int startx, int starty)
{
	super(startx, starty);
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class PlayerLevel2Fall4 extends PlayerLevel2
{
protected StateImageLibrary ladderimages;
protected int imagesindex = 0;
public PlayerLevel2Fall4(int startx, int starty)
{
	super(startx, starty);
	ladderimages = new StateImageLibrary();
	ladderimages.addImage("playerman100x150-1.png");
/*
	ladderimages.addImage("playerman100x150-ladder-2.png");
	ladderimages.addImage("playerman100x150-ladder-3.png");
	ladderimages.addImage("playerman100x150-ladder-4.png");
	ladderimages.addImage("playerman100x150-ladder-3.png");
	ladderimages.addImage("playerman100x150-ladder-2.png");
*/
}

public void fall()
{
	    if (playery > 150)
		playery = 150-1;

}

public Image getImage()
{
	if (imagesindex > 0)//FIXME1 6)//ladderimages.size())
		imagesindex = 0;
	return ladderimages.getImage(imagesindex);
}

public void moveP()//FIXME moveP
{
	
  	int foo = movePWithKeyLevel2(key);
	if (foo > 0 && getx() >= 394) {
		//FIXME mapx+=5.0;
      	}

  	shootP(key, friendlybullets);
}

public int movePWithKeyLevel2(int key)
{
	   int foo = 0;
           if (key == KeyEvent.VK_UP)//NOTE1
            {
		playery += -5;
		imagesindex++;
		foo = 1;
            }
            else if (key == KeyEvent.VK_DOWN)
            {
		playery += 5;
		imagesindex++;
		foo = 2;
            }
	    else 
	    {
		foo = 3;
		//direction = "nowhere";
		//prevdirection = "nowhere";
	    }

	   //if (foo > 0 && playerx >= 400)
		//playerx -= 5;
	return foo;
}

public void shootP(int key, LinkedList<Bullet> l)
{
            if (key == KeyEvent.VK_F)
            {
		if (prevdirection == "right") {
			Bullet bullet = new Bullet(getx()+50,gety()+80,"bullet16x16-1.png");
			bullet.setdx(+6);
			l.add(bullet);
		}
		else if (prevdirection == "left") {
			Bullet bullet = new Bullet(getx(),gety()+80,"bullet16x16-1.png");
			bullet.setdx(-6);
			l.add(bullet);
		}
		/*else if (direction == "nowhere") {
			Bullet bullet = new Bullet(getx(),gety()+80,"bullet16x16-1.png");
			bullet.setdx(-6);
			l.add(bullet);
		}*/
            }
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class PlayerLevel2 extends Player
{
String prefix = "./pics/";
Image leftimagestanding, rightimagestanding,leftshootimage, rightshootimage;
String direction = "nowhere", prevdirection = "right";
StateImageLibrary imagesleft;
protected int imagesindex = 0;
public PlayerLevel2(int startx, int starty)
{
	super(startx, starty);
	leftimagestanding = new ImageIcon(prefix+"playerman100x150-left-1.png").getImage();
	rightimagestanding = new ImageIcon(prefix+"playerman100x150-1.png").getImage();
	leftshootimage = new ImageIcon(prefix+"playerman100x150-left-1.png").getImage();
	rightshootimage = new ImageIcon(prefix+"playerman100x150-1.png").getImage();
	images = new StateImageLibrary();
        images.addImage("playerman100x150-1.png");	
/*        images.addImage("playerman100x150-walk-right-2.png");	
        images.addImage("playerman100x150-walk-right-3.png");	
        images.addImage("playerman100x150-walk-right-4.png");	
        images.addImage("playerman100x150-walk-right-5.png");	
        images.addImage("playerman100x150-walk-right-6.png");	
        images.addImage("playerman100x150-walk-right-7.png");	
        images.addImage("playerman100x150-walk-right-8.png");	
        images.addImage("playerman100x150-walk-right-9.png");	
        images.addImage("playerman100x150-walk-right-10.png");	
        images.addImage("playerman100x150-walk-right-11.png");	
*/	imagesleft = new StateImageLibrary();
        imagesleft.addImage("playerman100x150-left-1.png");	
/*        imagesleft.addImage("playerman100x150-walk-left-2.png");	
        imagesleft.addImage("playerman100x150-walk-left-3.png");	
        imagesleft.addImage("playerman100x150-walk-left-4.png");	
        imagesleft.addImage("playerman100x150-walk-left-5.png");	
        imagesleft.addImage("playerman100x150-walk-left-6.png");	
        imagesleft.addImage("playerman100x150-walk-left-7.png");	
        imagesleft.addImage("playerman100x150-walk-left-8.png");	
        imagesleft.addImage("playerman100x150-walk-left-9.png");	
        imagesleft.addImage("playerman100x150-walk-left-10.png");	
        imagesleft.addImage("playerman100x150-walk-left-11.png");	
*/
}

public Image getImage()
{
	//FIXME1
	if (imagesindex > 0)//11)//NOTE hardcoded number of images
		imagesindex = 0; 

	if (key == KeyEvent.VK_F && prevdirection == "left")
		return leftshootimage; 
	else if (key == KeyEvent.VK_F && prevdirection == "right")
		return rightshootimage; 
	
	if (direction == "right")
		return images.getImage(imagesindex);
	else if (direction == "left")
		return imagesleft.getImage(imagesindex);
	//else if (prevdirection == "nowhere")
	//	return rightimagestanding;
	else
		return images.getImage();
}

public void moveP()//FIXME moveP
{
  	int foo = movePWithKeyLevel2(key);
	if (foo > 0 && getx() >= 394) {
		//FIXME mapx+=5.0;
      	}

  	shootP(key, friendlybullets);
	fall();
}

public void fall()
{
	    if (jumpcounter > 0) {
	    	playery -= 3*jumpcounter++;
		//playerx +=15;
	   }
	   if (jumpcounter > 11)
		jumpcounter = 0;

	    playery += 3;
	    if (playery > 400)
		playery = 400-1;

}

public int movePWithKeyLevel2(int key)
{
	   int foo = 0;
           if (key == KeyEvent.VK_LEFT)//NOTE1
            {
		playerx += -5;
		direction = "left";
		prevdirection = "left";
		imagesindex++;
		foo = 1;
            }
            else if (key == KeyEvent.VK_RIGHT)
            {
		playerx += 5;
		direction = "right";
		prevdirection = "right";
		imagesindex++;
		foo = 2;
            }
	    else if (key == KeyEvent.VK_UP)
	    {
		jumpcounter++;
	    }
	    else 
	    {
		//direction = "nowhere";
		//prevdirection = "nowhere";
	    }

	   if (foo > 0 && playerx >= 400)
		playerx -= 5;
	return foo;
}

public void shootP(int key, LinkedList<Bullet> l)
{
            if (key == KeyEvent.VK_F)
            {
		if (prevdirection == "right") {
			Bullet bullet = new Bullet(getx()+50,gety()+80,"bullet16x16-1.png");
			bullet.setdx(+6);
			l.add(bullet);
		}
		else if (prevdirection == "left") {
			Bullet bullet = new Bullet(getx(),gety()+80,"bullet16x16-1.png");
			bullet.setdx(-6);
			l.add(bullet);
		}
		/*else if (direction == "nowhere") {
			Bullet bullet = new Bullet(getx(),gety()+80,"bullet16x16-1.png");
			bullet.setdx(-6);
			l.add(bullet);
		}*/
            }
}

public boolean collisionLevel2(Entity e, int mapx)
{
	if (distance(e.getx()-mapx, playerx, e.gety(), playery) < 30) {
		System.out.println("collision with player...gameover.");
		System.exit(99);	
		return true;
	}
	else
		return false;
}
};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class PlayerLevel3 extends Player
{
String prefix = "./pics/";
Image leftimagestanding, rightimagestanding,leftshootimage, rightshootimage;
String direction = "nowhere", prevdirection = "right";
StateImageLibrary imagesleft;
protected int imagesindex = 0;
public PlayerLevel3(int startx, int starty)
{
	super(startx, starty);
	leftimagestanding = new ImageIcon(prefix+"playerman100x150-left-1.png").getImage();
	rightimagestanding = new ImageIcon(prefix+"playerman100x150-1.png").getImage();
	leftshootimage = new ImageIcon(prefix+"playerman150x150-shoot-left-1.png").getImage();
	rightshootimage = new ImageIcon(prefix+"playerman150x150-shoot-right-1.png").getImage();
	images = new StateImageLibrary();
        images.addImage("playerman100x150-walk-right-1.png");	
        images.addImage("playerman100x150-walk-right-2.png");	
        images.addImage("playerman100x150-walk-right-3.png");	
        images.addImage("playerman100x150-walk-right-4.png");	
        images.addImage("playerman100x150-walk-right-5.png");	
        images.addImage("playerman100x150-walk-right-6.png");	
        images.addImage("playerman100x150-walk-right-7.png");	
        images.addImage("playerman100x150-walk-right-8.png");	
        images.addImage("playerman100x150-walk-right-9.png");	
        images.addImage("playerman100x150-walk-right-10.png");	
        images.addImage("playerman100x150-walk-right-11.png");	
	imagesleft = new StateImageLibrary();
        imagesleft.addImage("playerman100x150-walk-left-1.png");	
        imagesleft.addImage("playerman100x150-walk-left-2.png");	
        imagesleft.addImage("playerman100x150-walk-left-3.png");	
        imagesleft.addImage("playerman100x150-walk-left-4.png");	
        imagesleft.addImage("playerman100x150-walk-left-5.png");	
        imagesleft.addImage("playerman100x150-walk-left-6.png");	
        imagesleft.addImage("playerman100x150-walk-left-7.png");	
        imagesleft.addImage("playerman100x150-walk-left-8.png");	
        imagesleft.addImage("playerman100x150-walk-left-9.png");	
        imagesleft.addImage("playerman100x150-walk-left-10.png");	
        imagesleft.addImage("playerman100x150-walk-left-11.png");	
}

public Image getImage()
{

	if (imagesindex > 11)//NOTE hardcoded number of images
		imagesindex = 0; 

	if (key == KeyEvent.VK_F && prevdirection == "left")
		return leftshootimage; 
	else if (key == KeyEvent.VK_F && prevdirection == "right")
		return rightshootimage; 
	
	if (direction == "right")
		return images.getImage(imagesindex);
	else if (direction == "left")
		return imagesleft.getImage(imagesindex);
	//else if (prevdirection == "nowhere")
	//	return rightimagestanding;
	else
		return images.getImage();
}

public void moveP()//FIXME moveP
{
  	int foo = movePWithKeyLevel3(key);
	if (foo > 0 && getx() >= 394) {
		//FIXME mapx+=5.0;
      	}

  	shootP(key, friendlybullets);
	fall();
}

public void fall()
{
	    if (jumpcounter > 0) {
	    	playery -= 3*jumpcounter++;
		//playerx +=15;
	   }
	   if (jumpcounter > 11)
		jumpcounter = 0;

	    playery += 3;
	    if (playery > 400)
		playery = 400-1;

}

public int movePWithKeyLevel3(int key)
{
	   int foo = 0;
           if (key == KeyEvent.VK_LEFT)//NOTE1
            {
		playerx += -5;
		direction = "left";
		prevdirection = "left";
		imagesindex++;
		foo = 1;
            }
            else if (key == KeyEvent.VK_RIGHT)
            {
		playerx += 5;
		direction = "right";
		prevdirection = "right";
		imagesindex++;
		foo = 2;
            }
	    else if (key == KeyEvent.VK_UP)
	    {
		jumpcounter++;
	    }
	    else 
	    {
		//direction = "nowhere";
		//prevdirection = "nowhere";
	    }

	   if (foo > 0 && playerx >= 400)
		playerx -= 5;
	return foo;
}

public void shootP(int key, LinkedList<Bullet> l)
{
            if (key == KeyEvent.VK_F)
            {
		if (prevdirection == "right") {
			Bullet bullet = new Bullet(getx()+50,gety()+80,"bullet16x16-1.png");
			bullet.setdx(+6);
			l.add(bullet);
		}
		else if (prevdirection == "left") {
			Bullet bullet = new Bullet(getx(),gety()+80,"bullet16x16-1.png");
			bullet.setdx(-6);
			l.add(bullet);
		}
		/*else if (direction == "nowhere") {
			Bullet bullet = new Bullet(getx(),gety()+80,"bullet16x16-1.png");
			bullet.setdx(-6);
			l.add(bullet);
		}*/
            }
}

public boolean collisionLevel3(Entity e, int mapx)
{
	if (distance(e.getx()-mapx, playerx, e.gety(), playery) < 30) {
		System.out.println("collision with player...gameover.");
		System.exit(99);	
		return true;
	}
	else
		return false;
}
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

class PlayerLevel4 extends Player
{
String prefix = "./pics/";
public PlayerLevel4(int startx, int starty)
{
	super(startx, starty);

	images = new StateImageLibrary();
	images.addImage("shiphighelf112x64-1.png");
}

public Image  getImage()
{
	return images.getImage();
}

public void shootP(int key, LinkedList<Bullet> l)
{
            if (key == KeyEvent.VK_F)
            {
	//	if (direction == "right") 
		{
			Bullet bullet = new Bullet(getx()+16,gety()+10,"bullet24x24-2.png");
			bullet.setdx(+6);
			l.add(bullet);
		}
            }
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class Room1 extends Room
{
private LinkedList<Enemy> temp = new LinkedList<Enemy>();
public Room1(LinkedList<Enemy> enemies, AIengine aiengine)
{
	super();

}

public void addPart0(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	enemies.add(new EnemyProbe(100,10, "shipred50x50-1.png",aiengine));
    	enemies.add(new EnemyProbe(200,10, "shipred50x50-1.png",aiengine));
    	enemies.add(new EnemyProbe(300,10, "shipred50x50-1.png",aiengine));
    	enemies.add(new EnemyProbe(400,10, "shipred50x50-1.png",aiengine));
    	enemies.add(new EnemyProbe(500,10, "shipred50x50-1.png",aiengine));
    	enemies.add(new EnemyProbe(600,10, "shipred50x50-1.png",aiengine));
    	enemies.add(new EnemyProbe(700,10, "shipred50x50-1.png",aiengine));
}

public void addPart1(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	Enemy e = new EnemyProbe(230,-50, "shipred50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyProbe(130,-50, "shipred50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyProbe(400,-50, "shipred50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyProbe(670,-50, "shipred50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
	e = new EnemyProbe5(230,-50, "shipred50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
}

public void addPart2(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	Enemy e = new EnemyProbe(230,-50, "shipred50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyProbe(570,-50, "shipred50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
}

public void addPart3(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
	Enemy e = new EnemyStealth(300,-100, "shipgrey100x100-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyStealth(400,-100, "shipgrey100x100-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyStealth(100,-100, "shipgrey100x100-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyStealth(700,-100, "shipgrey100x100-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
}

public void addPart4(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	Enemy e = new EnemyScoutShip(600,-112, "shipwhite50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyScoutShip(500,-112, "shipwhite50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyScoutShip(400,-112, "shipwhite50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
	e = new EnemyPowerup1(300, 0, "powerup64x64-1.png", aiengine);
	addPartEnemies(enemies,aiengine, e);
}

public void addPart5(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}

public void addPart6(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
	Enemy e = new EnemyDuergarShip1(200,10, "shipduergar50x50-1.png",200,10,0.5,aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyDuergarShip1(500,10, "shipduergar50x50-1.png",500,10,0.5,aiengine);
	addPartEnemies(enemies,aiengine, e);

}

public void addPart7(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
/*
	for (int i = 0; i < spritecount; i++) {
    		Enemy e = new EnemyScoutShip(600,-112, "shipwhite50x50-1.png",aiengine);
		addPartEnemies(enemies,aiengine, e);
	}
*/
}

public void addPart8(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	Enemy e = new EnemyDuergarWizardShip1(400,12, "shipduergarwizard100x100-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
}

public void addPart9(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
 	Enemy e = new EnemyDuergarSatteliteShip(0,0, "shipaliengrey50x50-1.png", 4, aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyDuergarSatteliteShip(100,0, "shipaliengrey50x50-1.png", 4, aiengine);
	addPartEnemies(enemies,aiengine, e);
}

public void addPart10(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
	Enemy e = new EnemyDuergarSatteliteShip(300,0, "shipaliengrey50x50-1.png", 4, aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyDuergarSatteliteShip2(400,0, "shipaliengrey50x50-1.png", 4, aiengine);
	addPartEnemies(enemies,aiengine, e);
}


public void addPart11(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
	Enemy e = new EnemyProbe4(230,-50, "shipred50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
    	e = new EnemyProbe4(430,-50, "shipred50x50-1.png",aiengine);
	addPartEnemies(enemies,aiengine, e);
}

};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class Room2 extends Room
{
public Room2(LinkedList<Enemy> enemies, AIengine aiengine)
{
	super();

}

public void addPart0(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
	enemies.add(new EnemySnakeHeadLeft(880,265,"snakekhead150x100-left-1.png",aiengine));
    	//enemies.add(new EnemySnake1(800,400, "shipred50x50-1.png",aiengine));
}

public void addPart1(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	//enemies.add(new EnemyBasilisk(795,105, "basilisk200x150-1.png",aiengine));
	enemies.add(new EnemySnakeHeadLeft(1280,265,"snakekhead150x100-left-1.png",aiengine));
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class Room3 extends Room
{
public Room3(LinkedList<Enemy> enemies, AIengine aiengine)
{
	super();

}

public void addPart0(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	enemies.add(new EnemyTailBeast(100,310, "tailbeast50x50-1.png",10,aiengine));
    	enemies.add(new EnemySinus2(700,340, "shipred50x50-1.png",10,aiengine));
}

public void addPart1(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	enemies.add(new EnemyTailBeast(50,370, "tailbeasttail50x50-1.png",10,aiengine));
}
public void addPart2(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	enemies.add(new EnemyTailBeast(50,370, "tailbeasttail50x50-1.png",10,aiengine));
}
public void addPart3(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	enemies.add(new EnemyTailBeast(50,370, "tailbeasttail50x50-1.png",10,aiengine));
}
public void addPart4(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{
    	enemies.add(new EnemyTailBeast(50,370, "tailbeasttail50x50-1.png",10,aiengine));
}
};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public interface RoomInt2
{
public void addPart0(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart1(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart2(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart3(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart4(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart5(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart6(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart7(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart8(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart9(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart10(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
public void addPart11(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine);
};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public interface RoomInt
{
public void addPartEnemies(LinkedList<Enemy> enemies, AIengine aiengine, Enemy e);
public void addPartSprites(LinkedList<Sprite> sprites, AIengine aiengine, Sprite s);
};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.*;

public class Room implements RoomInt,RoomInt2
{
protected int activationPixel = 0;
public Room()
{}


public void addPartEnemies(LinkedList<Enemy> enemies, AIengine aiengine, Enemy e)
{
	enemies.add(e);
}
public void addPartSprites(LinkedList<Sprite> sprites, AIengine aiengine, Sprite s)
{
	sprites.add(s);
}

public void addPart0(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}

public void addPart1(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}
public void addPart2(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}
public void addPart3(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}
public void addPart4(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}
public void addPart5(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}
public void addPart6(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}
public void addPart7(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}
public void addPart8(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}
public void addPart9(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}
public void addPart10(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}
public void addPart11(LinkedList<Enemy> enemies, LinkedList<Sprite> sprites, AIengine aiengine)
{}

};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

import javax.swing.JFrame;

//import shooter.Game;


public class Shooter extends JFrame
{

  public Shooter()
  {
    add(new Game());
    setTitle("Pacman");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(800, 600);
    setLocationRelativeTo(null);
    setVisible(true);
  }

  public static void main(String[] args) {
      new Shooter();
  }
}
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

public class SpriteCodec1 extends Sprite
{

public SpriteCodec1(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename,aiengine);
        //NOTE FIXME aiengine.addObserver(this);
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

public class Sprite extends Entity 
{

public Sprite(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename);
        //NOTE FIXME aiengine.addObserver(this);
}

public void  shoot(LinkedList<Bullet> l, Player player)
{
	//subclass resp
}
public void  shootenemy(LinkedList<Enemy> l, Player player)
{
	//subclass resp
}
};
package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.util.*;

public class SpriteScoutShip extends Sprite
{

public SpriteScoutShip(int startx, int starty, String filename, AIengine aiengine)
{
	super(startx, starty, filename, aiengine);
	setdx(+2);
	setdy(-2);
}

};

package rocketman;
/*
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import java.awt.Toolkit;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.*;

class StateImageLibrary
{

private LinkedList<Image> images = new LinkedList<Image>();//FIXME static array size
String prefix = "./pics/";

private int index;
private int max;

public StateImageLibrary()
{
	index = 0;
	max = 0;
}

public void addImage(String filename)
{
      Image img = new ImageIcon(prefix+filename).getImage();
      images.add(img);
      max += 1;     	
}

public Image getImage()
{
      if (index >= max)
	index = 0;
      return images.get(index++);
}

public Image getImage(int idx)
{
      if (index >= max)
	index = 0;
      return images.get(idx);
}

};


\end{verbatim}
\end{mylisting}


\section{\large Conclusion}


\bibliographystyle{plain}
\bibliography{refs} % refs.bib

\end{document}


